{extend name='admin@main'}

{block name="content"}

<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body think-box-shadow padding-left-40">

        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs3 relative">
                <span class="color-green">文章分类</span>
                <select class="layui-select" required name="type" lay-search>
                    {foreach $class as $cate}
                    {if isset($vo.type) and $vo.type eq $cate.id}
                    <option selected value="{$cate.id}">{$cate.name|default=''}</option>
                    {else}
                    <option value="{$cate.id}">{$cate.name|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>
            <label class="layui-col-xs3 relative">
                <span class="color-green">文章标题</span>
                <input name="title_zh_cn"  class="layui-input" placeholder="请输入文章名称" value="{$vo.title_zh_cn|default=''}">
            </label>
            <label class="layui-col-xs3 relative">
                <span class="color-green">描述</span>
                <input name="des" class="layui-input" placeholder="请输入文章描述" value="{$vo.des|default=''}">
            </label>
            <label class="layui-col-xs3 relative">
                <span class="color-green">关键词</span>
                <input name="keyword" class="layui-input" placeholder="请输入文章关键词" value="{$vo.keyword|default=''}">
            </label>
        </div>
        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs3 relative">
                <span class="color-green">是否显示</span>
                <select class="layui-select" name="show">
                    {foreach ['1'=>'显示','0'=>'隐藏'] as $k=>$v}
                    <!--{eq name='$vo.show' value='$k.""'}-->
                    <option selected value="{$k}">{$v}</option>
                    <!--{else}-->
                    <option value="{$k}">{$v}</option>
                    <!--{/eq}-->
                    {/foreach}
                </select>
            </label>
            <label class="layui-col-xs3 relative">
                <span class="color-green">展示风格（0-默认，1-9风格，10-直接展示内容）</span>
                <input name="show_type"  class="layui-input" placeholder="展示风格" value="{$vo.show_type|default=''}">
            </label>
            <label class="layui-col-xs3 relative">
                <span class="color-green">层级</span>
                <input name="floor"  class="layui-input" placeholder="展示风格" value="{$vo.floor|default=''}">
            </label>
        </div>
        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs3 relative">
                <span class="color-green">图片</span>
                <div>
                    <input name="img" type="hidden" value="{$vo.img|default=''}">
                    <script>$('[name="img"]').uploadOneImage()</script>
                </div>
            </label>
        </div>
        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs3 relative">
                <span class="color-green">链接类型</span>
                <select class="layui-select" name="link_type">
                    {foreach ['0'=>'无跳转','1'=>'跳转链接','2'=>'跳转内容详情'] as $k=>$v}
                    <!--{eq name='$vo.link_type' value='$k.""'}-->
                    <option selected value="{$k}">{$v}</option>
                    <!--{else}-->
                    <option value="{$k}">{$v}</option>
                    <!--{/eq}-->
                    {/foreach}
                </select>
            </label>
            <label class="layui-col-xs6 relative">
                <span class="color-green">跳转链接</span>
                <input name="link_url" class="layui-input" placeholder="请输入跳转链接" value="{$vo.link_url|default=''}">
            </label>
        </div>

        <div class="layui-form-item layui-row layui-col-space15">
            
            <label class="layui-col-xs12 ">
                <span class="color-green label-required-prev">文章详情</span>
                <textarea name="content_zh_cn">{$vo.content_zh_cn|default=''|raw}</textarea>
            </label>
        </div>
        <div class="layui-form-item text-center">
            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
            <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消编辑</button>
            <button class="layui-btn" type="submit">保存文章</button>
        </div>

    </div>
</form>
{/block}

{block name='script'}
<script>
    window.form.render();
    require(['ckeditor', 'angular'], function () {
        window.createEditor('[name="content_zh_cn"]', {height: 400});
        var app = angular.module("GoodsForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            $rootScope.hsitoryBack = function () {
                $.msg.confirm('确定要取消编辑吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
        }

    })
</script>
{/block}
